<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <style>
    .table {
            border-collapse: collapse;
            margin: 0 auto;
            text-align: center;
        }
        .table td, .table th
        {
            border: 1px solid #cad9ea;
            color: #666;
            height: 30px;
        }
        .table thead th
        {
            background-color: #CCE8EB;
            width: 100px;
        }
        .table tr:nth-child(odd)
        {
            background: #fff;
        }
        .table tr:nth-child(even)
        {
            background: #F5FAFA;
        }
  </style>
</head>

<body>
  <div id = "app">
    <table class="table" table-hover>
      <thead>
        <th>id</th>
        <th>姓名</th>
        <th>年龄</th>
      </thead>
      <tbody>
        <!-- 只要使用了 v-for指令，那么一定要绑定一个 :key  属性，而且尽量将id作为key的属性值 -->
        <!-- :key 的值只能为 number或者string类型 而且不能重复，否则会报错 -->
        <tr v-for = "item in list" :key = "item.id">
          <td>{{item.id}}</td>
          <td>{{item.name}}</td>
          <td>{{item.age}}</td>
        </tr>
      </tbody>
    </table>
  </div>

  <script>
    const app = new Vue({
      el:"#app",
      data:{
        list:[
          {name:"张三",age:18,id:101},
          {name:"李四",age:19,id:102},
          {name:"王五",age:20,id:103}
        ]
      }
    })
  </script>
  </div>
</body>
</html>